import { UserItem } from './userModel';
import { AverageUserQueryParams } from './model';
import { BasicFetchResult } from '/@/api/model/baseMode';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/@/utils/http/axios/types';

enum Api {
  List = '/bannerManager/findPage',
  ChangeStatus = '/bannerManager/updateBanner',
  Delete = '/bannerManager/delBanner/',
  Edit = '/bannerManager/updateBanner',
  Add = '/bannerManager/addBanner',
  Getcitylist = '/bannerManager/cityList',
  Gettitlelist = '/bannerManager/findContents',
}

/**
 * @description: 查询普通用户列表
 */
export function ListApi(params: AverageUserQueryParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.List,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 改变用户状态
 */
export function ChangeStatusApi(params: UserItem, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.ChangeStatus,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 删除用户
 */
export function DeleteApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.Delete + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 新增销售人员
 */
export function AddApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.Add,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 编辑销售人员
 */
export function EditApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.Edit,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

// 获取城市列表
export function GetcitylistApi(mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.Getcitylist,
    },
    {
      errorMessageMode: mode,
    }
  );
}

// 获取标题列表
export function GettitlelistApi(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.Gettitlelist,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
